<?php

if( isset($title) )
	echo "<h1>".texo::translate($title).((!isset($noadd)||!$noadd) ? ' <a class="ibutton add" href="edit/?id=-1" title="'.texo::translate('add').'"> </a>' : '')."</h1>";

if( isset( $assets ) && is_array( $assets ) )
	foreach( array( 'js', 'css' ) as $assets_type )
		if( isset( $assets[$assets_type] ) )
			assets::instance( ) ->$assets_type( @$assets[$assets_type] );

if( isset( $filter ) )
{
if( is_array( $filter ) )
	echo $this ->smarty_function( '_filter', $filter );
elseif( is_object( $filter ) )
	echo $filter ->display( );
else
	echo $filter;
}


if( isset( $pager ) )
{
	$pager_out = '';
	if( isset( $pager['total'] ) && $pager['total'] > 1 )
	{
		$pager_out .= "<div id='pager'>";
		$pager_out .= $this ->smarty_function( '_pager', array( 'data' => $pager, 'list' => range( 1, $pager['total'] ) ) );
		$pager_out .= "</div>";
	}
	
	echo $pager_out;
}

if( isset( $items ) && count( $items ) )
{
	$cols = isset( $cols ) ? $cols : null;
	
	echo $this ->smarty_function( '_table', array( 'from' => $items, 'cols' => $cols, 'class' => 'plainlist' ) );
	$left = count( $items ) - $count;
	if( $left > 0 )
		echo sprintf(
			'<p>Кроме выведенных в базе есть еще %d %s...</p>',
			$left,
			_::plural( array( 'запись', 'записи', 'записей' ), $left )
			);
}
else
{
	echo "<p>".texo::translate( 'List empty' )."</p>";
}


if( isset( $pager ) )
	echo $pager_out;

